package com.bbt.dormassistant.controller;


import com.bbt.dormassistant.service.ActivityRoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;


@Api(tags = "活动室接口")
@RestController
@RequestMapping("/activityRoom")
public class ActivityRoomController {

    @Autowired
    private ActivityRoomService activityRoomService;


    @ApiOperation(value = "获取所有活动室信息")
    @GetMapping(value = "/listActivityRoom")
    public Map<String,Object> listActivityRoom(){
        Map<String,Object> map = new HashMap<>();
        map.put("activityRooms",activityRoomService.queryActivityRoom());
        return map;
    }


    @ApiOperation(value = "添加活动室信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "building", value = "楼栋", required = true, dataType = "String"),
            @ApiImplicitParam(name = "room", value = "楼层房间", required = true, dataType = "int"),
            @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "String")
    })
    @PostMapping(value = "/addActivityRoom")
    public Map<String,Object> addActivityRoom(@RequestParam(value = "building") String building,
                                              @RequestParam(value = "room") Integer room,
                                              @RequestParam(value = "userId") String userId){
        Map<String,Object> map =  new HashMap<>();
        boolean success =  activityRoomService.addActivityRoom(userId,building,room) ;
        map.put("success",success);
        return map;
    }


}
